package com.srit.system.service.impl;

import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.srit.system.bean.Grid;
import com.srit.system.bean.GridAttrRel;
import com.srit.system.bean.PageConfig;
import com.srit.system.dao.GridAttrRelDao;
import com.srit.system.dao.GridDao;
import com.srit.system.dao.PageConfigDao;
import com.srit.system.service.PageConfigService;

@Service
public class PageConfigServiceImpl implements PageConfigService {
	@Autowired
	private PageConfigDao pageConfigDao;
	@Autowired
	private GridDao gridDao;
	@Autowired
	private GridAttrRelDao gridAttrRelDao;

	@Override
	public PageConfig getById(int id) {
		PageConfig pageConfig = pageConfigDao.getById(id);
		List<Grid> gridList = gridDao.getListByConfigId(pageConfig.getId());
		for (Iterator<Grid> it = gridList.iterator(); it.hasNext();) {
			Grid grid = it.next();
			List<GridAttrRel> relList = gridAttrRelDao.getListByGridId(grid
					.getId());
			grid.setRelList(relList);
		}
		pageConfig.setGridList(gridList);
		return pageConfig;
	}

}
